<?php
/*
 *      nwfeditor.php
 *
 *      Copyright 2010 Rakitin Vitaliy <virak@ukr.net>
 *
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */
 
require_once($_SERVER['DOCUMENT_ROOT']."/classes/GUI/nwmsg.php");

class nwfeditor {

	private $dataset;
	private $uuid;
	public $owner;

	function __construct($uuid, $object) {
		$this->uuid = $uuid;
		$_SESSION[$this->uuid] = &$this;
		//$this->dataset = &$_SESSION["dataset"][$owner];
		$this->dataset = &$object;
	}

	function get() {

		$out = "<table id='$this->uuid' align='center'>";
		$out .= "<tr>";
		$out .= "<td><input ";
		//if (($this->dataset->isedit or $this->dataset->isinsert or !$this->dataset->doinsert)) {$out .= "disabled ";} 
		$out .= "type='button' name='insert' value='insert' onclick=message('$this->uuid','insert','',0);></td>";
		$out .= "<td><input ";
		//if (($this->dataset->isedit or $this->dataset->isinsert or !$this->dataset->doedit)) {$out .= "disabled ";} 
		$out .= "type='button' name='edit' value='edit' onclick=message('$this->uuid','edit','',0);></td>";
		$out .= "<td><input ";
		//if (($this->dataset->isedit or $this->dataset->isinsert or !$this->dataset->dodelete)) {$out .= "disabled ";} 
		$out .= "type='button' name='delete' value='delete' onclick=message('$this->uuid','delete','',0);></td>";
		$out .= "</table>";
		return $out;
	}

	function delete() {

	}

	function insert() {
		$item = $this->dataset->items->add();
		$this->dataset->itemform($item->uuid)->show();
	}

	function edit() {
		$this->dataset->itemform($this->dataset->select)->show();
	}
	
	function update() {
		$answer = &$_SESSION['answer'];
        $answer[] = array('update',$this->uuid,$this->get());
	}
}
?>
